<?php
if ( !isset($_SESSION) ) { session_start(); }

if (isset($_SESSION['perm']))
{
	$sperm = $_SESSION['perm'];
	// Nav If user is logged in
	if ($sperm == 1) {
		// ADMIN
		$nav = array(
			array(
				'title' => 'Search',
				'link' => 'index.php?l=search'		
			),
			array(
				'title' => 'Contracts',
				'link' => 'index.php?l=contracts'		
			),
			array(
				'title' => 'Staff',
				'link' => 'index.php?l=staff'		
			),
			array(
				'title' => 'Requests',
				'link' => 'index.php?l=requests'		
			),
			array(
				'title' => 'Account',
				'link' => 'index.php?l=account'		
			),
			array(
				'title' => 'Logout',
				'link' => 'index.php?l=logout'		
			)
		);
	}
	else if ($sperm == 2) {
		// CLIENT
		$nav = array(
			array(
				'title' => 'Search',
				'link' => 'index.php?l=search'		
			),
			array(
				'title' => 'Contracts',
				'link' => 'index.php?l=contracts'		
			),
			array(
				'title' => 'Account',
				'link' => 'index.php?l=account'		
			),
			array(
				'title' => 'Help',
				'link' => 'index.php?l=clienthelp'		
			),
			array(
				'title' => 'Logout',
				'link' => 'index.php?l=logout'		
			)
		);
	}
	else if ($sperm == 3) {
		// STAFF
		$nav = array(
			array(
				'title' => 'Search',
				'link' => 'index.php?l=search'		
			),
			array(
				'title' => 'Account',
				'link' => 'index.php?l=account'		
			),
			array(
				'title' => 'Help',
				'link' => 'index.php?l=staffhelp'		
			),
			array(
				'title' => 'Logout',
				'link' => 'index.php?l=logout'		
			)
		);
	}
}
else
{
	// Default nav when not logged in
	$nav = array(
		array(
			'title' => 'About',
			'link' => 'index.php?l=home'		
		),
		array(
			'title' => 'Login',
			'link' => 'index.php?l=login'		
		),
		array(
			'title' => 'Sign Up',
			'link' => 'index.php?l=signup'		
		)
	);	
}

?>

<ul>
<?php
	// Display navigation
	foreach ($nav as $n)
	{
		echo '<li><a href="'.$n['link'].'">'.$n['title'].'</a></li>';	
	}
	
	if (isset($_SESSION['userId'])) { echo '<div style="float:right;text-align:right;margin-right:20px;">Logged in as '.$_SESSION['user'].'&nbsp;-&nbsp;ID:'.$_SESSION['userId'].'</div>'; }
?>
</ul>
